<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <title>登录</title>
    <link th:href="@{/static/favicon.ico}" rel="shortcut icon">
    <link th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/static/css/font-awesome.css}" rel="stylesheet">
    <link th:href="@{/static/css/animate.css}" rel="stylesheet">
    <link th:href="@{/static/css/style.css}" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h2 class="logo-name">合约APP</h2>
        </div>
        <h2>欢迎使用</h2>
        <form class="m-t" role="form" action="#">
            <div class="form-group">
                <input id="username" type="email" class="form-control" placeholder="用户名" required="">
            </div>
            <div class="form-group">
                <input id="password" type="password" class="form-control" placeholder="密码" required="">
            </div>
            <button type="button" class="btn btn-primary block full-width m-b" onclick="login()">登 录</button>
        </form>
    </div>
</div>

<!-- 全局js -->
<script th:src="@{/static/plugins/jquery/jquery-3.4.1.min.js}"></script>
<script th:src="@{/static/plugins/layer/layer.js}"></script>
<script th:src="@{/static/plugins/bootstrap/js/bootstrap.min.js}"></script>
<script>
    function login() {
        let username = $('#username').val();
        let pwd = $('#password').val();
        if (username.length == 0 || pwd.length == 0 || username.trim().length == 0 || pwd.trim().length == 0) {
            return false;
        }
        $.ajax({
            type: "post",
            url: "login",
            data: {"username": username, "password": pwd, "captcha": ""},
            success: function (r) {
                if (r.code == 200) {
                    location.href = './index';
                } else {
                    parent.layer.msg(r.msg)
                }
            }
        });
    }
</script>
</body>
</html>
